<!DOCTYPE html>
<!-- saved from url=(0022)http://localhost:8080/ -->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="browsermode" content="application">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="Cache" content="no-cache">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
    <!-- 禁止百度转码 -->
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <!-- uc强制竖屏 -->
    <meta name="screen-orientation" content="portrait">
    <!-- QQ强制竖屏 -->
    <meta name="x5-orientation" content="portrait">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta name="format-detection" content="telephone=no">
    <title>申请成为掌柜</title>
    <link rel="stylesheet" href="${request.contextPath}/web/css/reset.css?v=${verison!}">
    <link rel="stylesheet" href="${request.contextPath}/web/css/base.css?v=${verison!}">
    <link rel="stylesheet" href="${request.contextPath}/web/css/shopkeeper-apply.css?v=${verison!}">
    <link rel="stylesheet" href="${request.contextPath}/web/css/ydui.css">
    <link rel="stylesheet" href="${request.contextPath}/plug/layui/css/layui.css" media="all">
</head>
<body style="background-color: rgb(245, 245, 245);">
<div data-role="page">
    <div class="app">
        <div class="shopkeeperApply absolute router">
            <div class="list">
                <div class="item acea-row row-between-wrapper">
                    <div class="name">姓&nbsp; &nbsp; &nbsp; &nbsp;名</div>
                    <input type="text" placeholder="请输入姓名" required="required" id="name">
                </div>
                <div class="item acea-row row-between-wrapper">
                    <div class="name">执照号码</div>
                    <input type="text" placeholder="请输入执照号码" required="required" id="zzhm">
                </div>
                <div class="item acea-row row-between-wrapper">
                    <div class="upload-name">营业执照</div>
                    <div class="upload-credentials">
                        <img src="${request.contextPath}/web/images/upload-default1.jpg" alt=""/>
                        <input type="hidden" class="file1">
                        <form method="post" enctype="multipart/form-data" action="" class="g-core-image-upload-form">
                            <input name="file" type="file" accept="image/*"  id="file1" onchange="fileChange(this,'file1')">
                        </form>
                    </div>
                </div>
                <div class="item acea-row row-between-wrapper">
                    <div class="upload-name">个人身份证</div>
                    <div class="upload-credentials">
                        <img src="${request.contextPath}/web/images/upload-default.png" alt=""/>
                        <input type="hidden" class="file2">
                        <form method="post" enctype="multipart/form-data" action="" class="g-core-image-upload-form">
                            <input name="file" type="file" accept="image/*" id="file2" onchange="fileChange(this,'file2')">
                        </form>
                    </div>
                    <div class="upload-credentials">
                        <img src="${request.contextPath}/web/images/upload-default2.png" alt=""/>
                        <input type="hidden" class="file3">
                        <form method="post" enctype="multipart/form-data" action="" class="g-core-image-upload-form">
                            <input name="file" type="file" accept="image/*"  id="file3" onchange="fileChange(this,'file3')">
                        </form>
                    </div>
                </div>
            </div>
            <a class="keepBnt bg-color-red" onclick="buyBoss()">确认</a>
        </div>
    </div>
    <#include "include/right.html" />
</div>
</body>
<script type="text/javascript" src="${request.contextPath}/web/js/media_750.js"></script>
<script type="text/javascript" src="${request.contextPath}/web/js/jquery.min.js"></script>
<script type="text/javascript" src="${request.contextPath}/web/js/jquery.mobile.min.js"></script>
<script type="text/javascript" src="${request.contextPath}/web/js/ydui.js"></script>
<script type="text/javascript" src="${request.contextPath}/web/js/common.js"></script>
<script src="${request.contextPath}/js/layer.js"></script>
<script type="text/javascript" src="${request.contextPath}/js/ajaxfileupload.js"></script>
<script>

     function fileChange(obj,fileId){
        var reader=new FileReader();
        var file=obj.files[0];
        reader.readAsDataURL(file);
        reader.onload=function(){
            $(obj).parent().parent().find("img").attr("src",reader.result);
            $.ajaxFileUpload({
		        url:"${request.contextPath}/web/upload",
		        secureuri:false,                           //是否启用安全提交,默认为false
		        fileElementId:fileId,               //文件选择框的id属性
		        dataType:'JSON',                           //服务器返回的格式,可以是json或xml(需要大写)等     text
		        success:function(data, status){            //服务器响应成功时的处理函数
		            console.log(data);
		            data = data.replace(/<pre.*?>/g, ''); // ajaxFileUpload会对服务器响应回来的text内容加上
		            data = data.replace("</pre>", ''); // 本例中设定上传文件完毕后,服务端会返回给前台[0`filepath]
		            data = eval("("+data+")");
		             console.log(data.data);
		            if (data.code == 200) {
                        $("."+fileId).val(data.data);
                          layer.msg("图片上传完成")
		            }else{
                        layer.msg(data.msg)
		            }
		        },
		        error:function(data, status, e){ //服务器响应失败时的处理函数
		           layer.msg("上传失败")
		        }
		     });
        }
    }
    function buyBoss(){
        var obj = new Object();
        obj["name"] = $.trim($("#name").val());
        obj["zzhm"] =  $.trim($("#zzhm").val());
        obj["type"] =  3;
        obj["yyzzImage"] = $.trim($(".file1").val());
        obj["sfzhImage1"] = $.trim($(".file2").val());
        obj["sfzhImage2"] = $.trim($(".file3").val());
        if("" == obj["name"]){
            layer.msg("姓名不能为空！")
            return;
        }
        if("" == obj["zzhm"]){
            layer.msg("执照号码不能为空！")
            return;
        }
        if("" == obj["yyzzImage"]){
            layer.msg("请等待营业执照上传完成！")
            return;
        }
        if("" == obj["sfzhImage1"]){
            layer.msg("请等待身份证正面上传完成！")
            return;
        }
        if("" == obj["sfzhImage2"]){
            layer.msg("请等待身份证背面上传完成！")
            return;
        }
        $.ajax({
              type: 'POST',
              url: '${request.contextPath}/web/applyInfo/add',
              data: JSON.stringify(obj),
              dataType:'json',
              contentType:'application/json',
              success: function(data){
                  if(data.code==200){
                     window.location.reload();
                  }else{
                     layer.msg(data.msg)
                  }
              }
        });
    }
</script>
</html>